package net.huashitong.supervision.task.dao;

import com.sirdc.modules.core.dao.GenericQuery;
import com.sirdc.modules.core.dao.StringDao;
import net.huashitong.supervision.task.entity.TaskLogNew;
import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: ling
 * Date: 2019/8/19
 * Time: 20:22
 * To change this template use File | Settings | File Templates.
 * Description:
 */
@Repository
public class TaskLogNewDao extends StringDao<TaskLogNew> {
    //    当前任务流程
    public List<TaskLogNew> getByUnitId(String taskUnitId) {
        GenericQuery query = createQuery("obj");
        query.append(" and taskUnitId =:taskUnitId").setParam("taskUnitId", taskUnitId);
        return query.listResult();
    }

    /**
     * 删除
     * @param taskUnitIds
     */
    public void deleteByUnitIds(List<String> taskUnitIds) {
        StringBuffer hql = (new StringBuffer("delete from TaskLogNew")).append(" obj where obj.taskUnitId in(:taskUnitIds)");
        Query query = this.getSession().createQuery(hql.toString());
        query.setParameterList("taskUnitIds", taskUnitIds);
        query.executeUpdate();
    }
}
